package com.yoomiito.app.adapter.act.free;

import androidx.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yoomiito.app.R;
import com.yoomiito.app.model.home.FreeGoodsInfo;
import com.yoomiito.app.utils.ImageLoader;

import java.util.List;

public class FreeGoodsAdapter extends BaseQuickAdapter<FreeGoodsInfo, BaseViewHolder> {
    public FreeGoodsAdapter(@Nullable List<FreeGoodsInfo> data) {
        super(R.layout.item_goods_4, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FreeGoodsInfo item) {
        ImageView iv = helper.getView(R.id.goods_iv);
        ImageLoader.getInstance().into(iv.getContext(), item.getImageUrl(), iv);
        ImageView goodsSourceLogoIv = helper.getView(R.id.goods_source_logo);
        goodsSourceLogoIv.setImageResource(item.getSource().equals("1") ? R.mipmap.tmall : R.mipmap.tb);
        helper.setText(R.id.goods_name, item.getTitle());
    }
}
